<template>
  <div>
    <el-container>
      <el-header style="background-color:#0270c1">
        <!-- 导航栏 -->
        <div>
          <!-- 系统名称 -->
          <div style="float:left;background-color:#008df7;margin-left: -20px; width: 13.5%;">
            <span style="color:#fff;">OA | 办公系统</span>
          </div>
          <!-- 中 -->
          <div style="color:#fff;float:left;margin-left: 20px;">
            <!-- 首页 -->
            <div style="float:left">
              <router-link to="/yindex" style="color:#fff">
                <span style="font-size:20px" class="el-icon-s-home"></span>
              </router-link>
            </div>
            <!-- 菜单 -->
            <div style="float:left;margin-left: 32px;">
              <span style="font-size:20px" class="el-icon-menu"></span>
            </div>
            <!-- 搜索框 -->
            <div
              style="float:left;background-color:#0267b2;margin-left: 120px;
              margin-left: 120px; height: 40px; line-height: 40px;margin-top: 7px;z-index:100"
            >
              <div style="float:left">
                <div style="float:left">
                  <select style="color:#fff;background-color:#0267b2">
                    <option>微搜</option>
                    <option>活动2</option>
                    <option>活动3</option>
                  </select>
                  <span>|</span>
                </div>
                <div style="float:left;background-color:#0267b2 !important">
                  <el-input placeholder="请输入关键字搜索" v-model="input4">
                    <i slot="suffix" class="el-input__icon el-icon-search"></i>
                  </el-input>
                </div>
              </div>
            </div>
          </div>
          <!-- 右 -->
          <div style="float:right">
            <div style="float:left;font-size:20px;color:#fff;margin-right: 180px;">
              <div style="float:left;">
                <span class="el-icon-message-solid"></span>
              </div>
              <div style="float:left;margin-left:10px">
                <span class="el-icon-s-comment"></span>
                <span>|</span>
              </div>
              <!-- 头像 -->
              <div style="position: absolute;top: 15px; right: 150px;">
                <el-avatar :src="head_pic"></el-avatar>
              </div>
              <div style="position: absolute;right: 74px;top: 8px;">
                <!-- 登录角色 -->
                <el-dropdown @command="handleCommand">
                  <span class="el-dropdown-link" style="color:#fff">
                    {{ename}}
                    <i class="el-icon-arrow-down el-icon--right"></i>
                  </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item command="a">我的资料</el-dropdown-item>
                    <el-dropdown-item command="b">修改密码</el-dropdown-item>
                    <el-dropdown-item command="c">退出</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </div>
            </div>
          </div>
        </div>
        <!-- 左导航栏 -->
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-date"></i>
                <span>考勤模块</span>
              </template>
              <el-menu-item index="1-1">选项1</el-menu-item>
              <el-menu-item index="1-2">选项2</el-menu-item>
              <el-menu-item index="1-3">选项3</el-menu-item>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-d-caret"></i>
                <span>审批模块</span>
              </template>
              <el-menu-item index="2-1">选项1</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
              <el-menu-item index="2-3">选项3</el-menu-item>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-coin"></i>
                <span>财务模块</span>
              </template>
              <el-menu-item index="2-1">选项1</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
              <el-menu-item index="2-3">选项3</el-menu-item>
            </el-submenu>
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-time"></i>
                <span>任务模块</span>
              </template>
              <el-menu-item index="2-1">选项1</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
              <el-menu-item index="2-3">选项3</el-menu-item>
            </el-submenu>
             <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-user"></i>
                <span>用户模块</span>
              </template>
              <el-menu-item index="2-1">选项1</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
              <el-menu-item index="2-3">选项3</el-menu-item>
            </el-submenu>
             <el-submenu index="6">
              <template slot="title">
                <i class="el-icon-truck"></i>
                <span>后勤模块</span>
              </template>
              <el-menu-item index="2-1">选项1</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
              <el-menu-item index="2-3">选项3</el-menu-item>
            </el-submenu>
             <el-submenu index="7">
              <template slot="title">
                <i class="el-icon-office-building"></i>
                <span>部门模块</span>
              </template>
              <el-menu-item index="2-1">选项1</el-menu-item>
              <el-menu-item index="2-2">选项2</el-menu-item>
              <el-menu-item index="2-3">选项3</el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<style>
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #fff;
  color: #333;
  text-align: center;
  line-height: 160px;
  height: 1000px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-input--suffix .el-input__inner {
  padding-right: 30px;
  background-color: #0267b2;
  border: none;
  color: #fff;
}
</style>
<script>
export default {
  created() {
    this.ename = sessionStorage.getItem("ename");
    this.head_pic = sessionStorage.getItem("head_pic");
  },
  data() {
    return {
      input4: "",
      head_pic: "",
      ename: ""
    };
  },
  methods: {
    handleCommand(command) {
      if (command == "a") {
        this.$router.push("/updateuser");
      }
      if (command == "b") {
        this.$router.push("/updatepass");
      }
      if (command == "c") {
        // 是否退出
        this.$confirm("确认退出?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            //退出
            this.$axios
              .get("/comsumer/logOut?utel="+sessionStorage.getItem("utel"))
              .then(res => {
                if (res.data.statusCode == 200) {
                  sessionStorage.clear();
                  this.$router.push("/")
                  this.$message({ type: "success", message: "退出成功!" });
                }
              })
              .catch(error => {
                console.log(error);
              });
          })
          .catch(() => {
            this.$message({ type: "info", message: "已取消退出" });
          });
      }
    }
  }
};
</script>
